package com.yixq.soa.service.web;

import javax.servlet.Filter;

import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.filter.CharacterEncodingFilter;

import com.yixq.soa.service.comm.utils.SpringContextHolder;
import com.yixq.soa.service.web.utils.EnvironmentUtils;


public class CommWebConifg {
	/**
	 * 提供项目运行环境参数的读取.例如数据库的连接信息.redis的连接信息等所有在property文件里定义的属性.
	 * 
	 * @return
	 */
	@Bean
	EnvironmentUtils doorduEnv() {
		return new EnvironmentUtils();
	}
	
	/**
	 * 提供普通类访问Spring bean 的能力.
	 * 
	 * @return
	 */
	@Bean
	SpringContextHolder springContextHolder() {
		return new SpringContextHolder();
	}
	
	@Bean
	@Order(Ordered.HIGHEST_PRECEDENCE)
	Filter characterEncodingFilter() {
		CharacterEncodingFilter filter = new CharacterEncodingFilter();
		filter.setEncoding("UTF-8");
		filter.setForceEncoding(true);
		return filter;
	}
}
